Skip to content

Template selection after recording + Enhancement Refactoring #1109

Closed
duckduckhero wants to merge 18 commits intomainfrom
template-after-recording
Closed

Template selection after recording + Enhancement Refactoring #1109
duckduckhero wants to merge 18 commits intomainfrom
template-after-recording

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 8, 2025

📝 Walkthrough

Walkthrough

The changes introduce a user-selectable "auto enhance template" feature for recording sessions, refactor enhancement logic to pass template IDs explicitly, remove global config mutation and restoration during enhancement, and update localization metadata. State management and UI are adjusted to support template selection, and relevant store and mutation interfaces are updated accordingly.

Changes

File(s) Change Summary
apps/desktop/src/components/editor-area/index.tsx Refactored enhancement logic: removed config mutation/restoration, updated useEnhanceMutation to accept { triggerType, templateId }, simplified enhancement callbacks, and updated useAutoEnhance to use session store for template selection.
apps/desktop/src/components/editor-area/note-header/listen-button.tsx Added UI and logic for selecting an "auto enhance template" when stopping a recording session; updated state, queries, and event handlers to support template selection and persistence to session store.
apps/desktop/src/components/editor-area/floating-button.tsx Removed invalidation of the ["llm-connection"] query in the window focus handler after adding a template; now only invalidates ["templates"].
packages/utils/src/stores/ongoing-session.ts Added autoEnhanceTemplate property to session store state and a setter method for updating it.
apps/desktop/src/locales/en/messages.po
apps/desktop/src/locales/ko/messages.po
Updated source code reference line numbers for translation entries; added a new entry for "Auto (Default)".
apps/docs/data/i18n.json Incremented translation entry counts for English and Korean to reflect the new message; updated missing count for Korean.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RecordingControls
    participant OngoingSessionStore
    participant EditorArea
    participant useEnhanceMutation

    User->>RecordingControls: Stop recording (selects template)
    RecordingControls->>OngoingSessionStore: setAutoEnhanceTemplate(templateId)
    RecordingControls->>EditorArea: Trigger enhancement
    EditorArea->>useEnhanceMutation: mutate({ triggerType: "auto", templateId })
    useEnhanceMutation-->>EditorArea: Enhancement complete
Loading

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/desktop/src/locales/ko/messages.po (1)

374-376: New translation entry added but untranslated.

The "Auto (Default)" message has been added to the Korean translation file but remains untranslated (empty msgstr). This is expected for new strings.

Consider providing the Korean translation for "Auto (Default)" if localization is needed for this feature.

apps/desktop/src/components/editor-area/note-header/listen-button.tsx (1)

294-304: Consider optimizing query refetch behavior.

The queries have refetchOnWindowFocus: true which might cause unnecessary refetches. Consider if this is needed for the template selection feature.

If the templates and config don't change frequently, you might want to remove refetchOnWindowFocus: true to reduce unnecessary network calls:

  const configQuery = useQuery({
    queryKey: ["config"],
    queryFn: () => dbCommands.getConfig(),
-   refetchOnWindowFocus: true,
  });

  const templatesQuery = useQuery({
    queryKey: ["templates"],
    queryFn: () => dbCommands.listTemplates(),
-   refetchOnWindowFocus: true,
  });
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f91f1dd and 9cebb48.

📒 Files selected for processing (7)
  • apps/desktop/src/components/editor-area/floating-button.tsx (0 hunks)
  • apps/desktop/src/components/editor-area/index.tsx (6 hunks)
  • apps/desktop/src/components/editor-area/note-header/listen-button.tsx (8 hunks)
  • apps/desktop/src/locales/en/messages.po (10 hunks)
  • apps/desktop/src/locales/ko/messages.po (10 hunks)
  • apps/docs/data/i18n.json (1 hunks)
  • packages/utils/src/stores/ongoing-session.ts (3 hunks)
💤 Files with no reviewable changes (1)
  • apps/desktop/src/components/editor-area/floating-button.tsx
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{js,ts,tsx,rs}`: 1. No error handling. 2. No unused imports, variables, or functions. 3. For comments, keep it minimal. It should be about "Why", not "What".

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • packages/utils/src/stores/ongoing-session.ts
  • apps/desktop/src/components/editor-area/note-header/listen-button.tsx
  • apps/desktop/src/components/editor-area/index.tsx
🧬 Code Graph Analysis (1)
apps/desktop/src/components/editor-area/note-header/listen-button.tsx (3)
packages/ui/src/components/ui/popover.tsx (1)
  • Popover (85-85)
packages/utils/src/contexts/ongoing-session.tsx (1)
  • useOngoingSession (32-46)
packages/ui/src/components/ui/select.tsx (5)
  • Select (174-174)
  • SelectTrigger (174-174)
  • SelectValue (174-174)
  • SelectContent (174-174)
  • SelectItem (174-174)
🪛 GitHub Actions: .github/workflows/i18n.yaml
apps/docs/data/i18n.json

[error] 1-1: i18n data is not up-to-date. Please run 'task i18n' locally and commit the changes.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci (macos, macos-latest)
🔇 Additional comments (25)
packages/utils/src/stores/ongoing-session.ts (4)

16-16: Clean state property addition for template selection.

The autoEnhanceTemplate property is properly typed and follows the existing store pattern.


23-23: Action signature matches the expected pattern.

The setAutoEnhanceTemplate action is correctly typed and follows the store's naming conventions.


38-38: Appropriate initial state value.

Setting the initial value to null is correct for optional template selection.


67-73: Proper implementation following store patterns.

The setAutoEnhanceTemplate implementation correctly uses mutative for immutable updates and follows the existing pattern in the store.

apps/desktop/src/locales/en/messages.po (1)

374-376: New translation entry added correctly.

The "Auto (Default)" message has been properly added with the correct source reference and translation string.

apps/desktop/src/components/editor-area/note-header/listen-button.tsx (10)

9-9: New imports correctly added for template selection feature.

The database commands and Select UI components are properly imported and used throughout the component.

Also applies to: 14-14


227-227: Proper integration with ongoing session store.

The setAutoEnhanceTemplate action is correctly destructured and used to persist template selection.


230-230: Good popover state management.

Adding controlled state for the popover improves the user experience by allowing programmatic control.


237-248: Well-implemented template handling in stop session.

The handleStopSession function correctly accepts an optional template ID and sets it in the store before stopping the session.


251-251: Appropriate change to controlled popover.

Converting from uncontrolled to controlled popover enables better state management and user experience.


284-284: Proper state initialization for template selection.

The selectedTemplate state is appropriately initialized to "auto" as the default value.


306-312: Correct synchronization with config data.

The useEffect properly syncs the selected template with the stored configuration, with appropriate fallback to "auto".


314-317: Clean template ID conversion logic.

The handleStopWithTemplate function correctly converts "auto" to null for the API call.


334-350: Well-implemented template selection UI.

The Select component implementation is clean and properly handles the template options with appropriate fallback display.


363-363: Correct integration of template selection with stop action.

The stop button now properly calls handleStopWithTemplate to include the selected template in the stop action.

apps/desktop/src/components/editor-area/index.tsx (10)

92-93: LGTM!

The mutation hook definition is correct and follows the established pattern.


116-119: Clean refactoring to explicit template ID passing.

The callback correctly handles the "auto" template case and passes both the template ID and trigger type explicitly to the mutation.


122-123: Good simplification of the manual enhance trigger.

The callback correctly relies on the mutation's default behavior for template selection.


249-255: Well-designed API with proper defaults.

The object parameter pattern provides clarity and extensibility, while the default value maintains backward compatibility.


286-291: Verify the null template handling is intentional.

When templateId is explicitly null (from the "auto" template case), it won't fall back to the config's selected template. Please confirm this is the intended behavior for auto-enhancement.


296-298: Correct usage of the resolved template ID.

The template lookup properly uses the effective template ID determined by the fallback logic.


503-503: Type signature correctly updated.

The parameter type matches the updated mutation function signature.


506-507: Proper integration with ongoing session store.

The hook correctly retrieves the auto-enhance template state and its setter.


518-527: Good implementation of one-time template usage.

The code correctly applies the selected template during auto-enhancement and clears it afterward, preventing unintended reuse in subsequent sessions.


534-536: Dependency array correctly updated.

All referenced variables are properly included in the effect dependencies.

Comment on lines +4 to +5
"total": 283,
"missing": 283
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address the i18n pipeline failure.

The translation counts have been updated correctly to reflect the new "Auto (Default)" message, but the pipeline failure indicates the i18n data needs to be regenerated.

Please run task i18n locally and commit the changes to fix the pipeline failure as indicated in the GitHub Actions workflow.

🤖 Prompt for AI Agents
In apps/docs/data/i18n.json around lines 4 to 5, the translation counts are
updated but the i18n pipeline fails because the i18n data is not fully
regenerated. To fix this, run the `task i18n` command locally to regenerate the
i18n data files completely, then commit the updated files to resolve the
pipeline failure.

@duckduckhero duckduckhero deleted the template-after-recording branch July 8, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant